package com.cg.design.graphicdesignpattern.chainofresponsibility;

import org.junit.Test;

/**
 * Chain of Responsibility职责链模式测试类
 *
 * @program: LeetCode->ChainOfResponsibilityTest
 * @description: Chain of Responsibility职责链模式测试类
 * @author: cg
 * @create: 2022-03-27 11:31
 **/
public class ChainOfResponsibilityTest {

    @Test
    public void testChainOfResponsibility() {
        Support alice = new NoSupport("Alice");
        Support bob = new LimitSupport("Bob", 100);
        Support charlie = new SpecialSupport("Charlie", 429);
        Support diana = new LimitSupport("Diana", 200);
        Support elmo = new OddSupport("Elmo");
        Support fred = new LimitSupport("Fred", 300);
        // 形成职责链
        alice.setNext(bob).setNext(charlie).setNext(diana).setNext(elmo).setNext(fred);
        // 制造问题
        for (int i = 0; i < 500; i+=33) {
            alice.support(new Trouble(i));
        }
    }

}
